{include file="common:header" /}
{include file="common:side" /}
<div id="page-wrapper">
  <!-- 所有供应商管理-- 待审核供应商列表 -->
  <!--*************************** content部分开始 ******************-->
  <div class="container-fluid" id="m_main">
    <div class="row m-t-20">
      <div class="col-sm-12">
        <div class="white-box">
          <h2 class="box-title m-b-20">待审核供应商列表</h2>
          <!-- <p class="text-muted m-b-30">Data table example</p> -->
          <div class="row">
            <div class="col-sm-2">
              <div class="form-group">
                <div class="input-group">
                  <input type="text" id="start_time" name="start" class="form-control input-group-input-date" autocomplete="off" placeholder="开始时间" v-model="start_time">
                  <span class="input-group-btn input-group-btn-date">
                    <i class="mdi mdi-calendar-text fa-blue"></i>
                  </span>
                </div>
              </div>
            </div>
            <div class="col-sm-2">
              <div class="form-group">
                <div class="input-group">
                  <input type="text" id="end_time" name="end" class="form-control input-group-input-date" autocomplete="off" placeholder="结束时间" v-model="end_time">
                  <span class="input-group-btn input-group-btn-date">
                    <i class="mdi mdi-calendar-text fa-blue"></i>
                  </span>
                </div>
              </div>
            </div>
            <div class="col-sm-3">
              <div class="form-group">
                <div class="input-group">
                  <span class="input-group-btn input-group-btn-search">
                    <i class="fa fa-search fa-blue"></i>
                  </span>
                  <input type="text" id="search_input" name="" class="form-control input-group-input-search" placeholder="请输入供应商名称" v-model="company">
                </div>
              </div>
            </div>
            <div class=" col-sm-2">
              <div class="form-group">
                <button class="btn btn-outline btn-info" @click="pageTo(1)">查询</button>
              </div>
            </div>
          </div>
          <div class="table-responsive">
            <table id="myTable" class="table table-striped color-table info-table">
              <thead>
                <tr>
                  <th>申请时间</th>
                  <th>公司名称</th>
                  <th>联系人</th>
                  <th>联系电话</th>
                  <th>行业选择</th>
                  <th>主营商品</th>
                  <th>备注信息</th>
                  <th>管理员</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="(item,index) in dataList">
                  <td>{{item.create_date}}</td>
                  <td>{{item.company}}</td>
                  <td>{{item.contacts}}</td>
                  <td>{{item.contacts_phone}}</td>
                  <td>{{item.industry}}</td>
                  <td>{{item.main_commodity}}</td>
                  <td>{{item.remark}}</td>
                  <td>{{item.adusername}}</td>
                  <td>
                    <span class="edit info m-l-10" data-toggle="modal" data-target="#confirm1" @click="editId=item.id;editType=1;confirmMsg='确认通过？'">通过</span>
                    <span class="edit danger m-l-10" data-toggle="modal" data-target="#confirm1" @click="editId=item.id;editType=2;confirmMsg='确认不通过？'">不通过</span>
                  </td>
                </tr>
              </tbody>
            </table>
            <pagination :tr-all="trAll" :page-cur="pageCur" :page-all="pageAll" :page-size="pageSize" @page-to="pageTo" ref="c1"></pagination>
            <!-- 确认取消提示框 -->
            <confirm  class="modal fade" id="confirm1" tabindex="-1" role="dialog" :confirm-msg="confirmMsg" @yes-btn="doSubmit"></confirm>
          </div>
        </div>
      </div>
    </div>
    <!-- /.row -->
  </div>
  <!--*************************** content部分结束 ******************-->

  <!-- <footer class="footer text-center"> 2017 &copy; Ample Admin brought to you by themedesigner.in </footer> -->
</div>
{include file="common:js" /}
<script type="text/javascript" src="/web/js/search_list.js"></script>
{include file="common:footer" /}
{include file="component:pagination" /}
{include file="component:confirm" /}

  <script type="text/javascript">
    var vm = new Vue({
      el: '#m_main',
      data() {
        return {
          searchUrl: "/dboard/supplier/ajaxList", //搜索接口
          draw: '', //校验字段
          start_time:'',//开始时间
          end_time:'',//结束时间
          company:'',//供应商名称
          status:'0',//供应商名称
          dataList: [], //搜索列表数据
          trAll: 0, //数据总数
          pageAll: 0, //页码总数
          pageCur: 1, //当前页
          pageSize: 10, //每页数量
          confirmMsg: '', //confirm提示框内容
          editId:'',//操作的id
          editType:'',//操作的类型
        }
      },
      mounted() {
        this.realizeDatePicker();
        this.pageTo(1);
      },
      methods: {
        realizeDatePicker() {
          var that = this;
          $('#start_time').datepicker({
            autoclose: true,
            todayHighlight: true,
            language: "zh-CN",
            format: "yyyy/mm/dd"
          });
          $('#start_time').datepicker().on('hide', function (ev) {
            that.start_time = $("#start_time").val();
          });
          $('#end_time').datepicker({
            autoclose: true,
            todayHighlight: true,
            language: "zh-CN",
            format: "yyyy/mm/dd"
          });
          $('#end_time').datepicker().on('hide', function (ev) {
            that.end_time = $("#end_time").val();
          });
        },
        // 搜索当前页并渲染列表
        pageTo(page) {
          var that = this;
          var params = {
            start_time:that.start_time,
            end_time:that.end_time,
            company:that.company,
            status:that.status
          };
          searchList(that, page, params, (res) => {}, (fail) => {}, (error) => {})
        },
        // 上线1、下线2
        doSubmit(){
          var that = this;
          axios.post('/dboard/supplier/doUp',{id:that.editId,type:that.editType},{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res=>{
            if(res.data.Code==0){
              alert(res.data.Msg);
              $('#confirm1').modal('toggle');
              that.pageTo(that.pageCur);
            }else{
              alert(res.data.Msg);
              $('#confirm1').modal('toggle');
            }
          }).catch(err=>{})
        }
      }
    })
  </script>
